home *** CD-ROM | disk | FTP | other *** search
- Path: EU.net!sun4nl!ittpub!ittpub!nntp
- Newsgroups: comp.lang.c++
- Subject: Re: Exception Overhead
- Message-ID: <1996Mar21.131518.1809@ittpub>
- From: wil@ittpub.nl (Wil Evers)
- Date: 21 Mar 96 13:15:18 WET
- References: <31504001.27D7@datalytics.com>
- Distribution: world
- Nntp-Posting-Host: lintilla
-
- In article <31504001.27D7@datalytics.com> Rob Stewart
- <stew@datalytics.com> writes:
-
- > hfreeman wrote:
- > >
- > > When my apps throw exceptions, it is in truly exceptional situations,
- > > thus, I'm not overly concerned about performance when exceptions are
- > > thrown, but could someone please speak to the performance hits taken
- > > when exceptions are used but not thrown (ie. when try blocks are
- > > entered and exited). If a try block is used in a loop, is there a
- > > serious performance penalty.
- > >
- > > Thanks.
- >
- > The performance hit is implementation-dependent. The compiler
- > has to track which objects to destruct when an exception is
- > thrown at any point within a function, so just enabling
- > exception support invokes this overhead.
-
- That would be an overhead at compile time, not at run time.
-
- > A try block shouldn't incur much overhead, but I don't think it can
- > incur zero overhead. As a result, you should always minimize your
- > try/catch blocks--keeping them out of loops, for example.
-
- This is not necessarily true. There are implementations around that incur
- no speed penalty as long as no exceptions are thrown. These
- implementations have tables to determine what code to call to do stack
- unwinding, based on the address in the code where the exception is thrown.
- Of course, these tables take up space, but some linkers put these tables
- in a separate memory region. As a result, there will be no extra virtual
- memory management overhead as long as you don't throw an exception.
-
- - Wil
-
-
-
-
-